package dcl.software.filesync.convertor;


import java.io.IOException;

import javax.annotation.Resource;

import org.apache.tika.exception.TikaException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.xml.sax.SAXException;

@Controller
@RequestMapping(value = "transfer")
public class TransferController {
	@Resource
	private Parser parser;

	@RequestMapping(value = "addfile", method = RequestMethod.POST, headers = "content-type=multipart/form-data")
	@ResponseBody
	public String addFile(@RequestPart(value = "file[]", required = true) final MultipartFile multipartFile) throws IOException, SAXException, TikaException {

		return parser.parse(multipartFile.getInputStream());
	}
}
